<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>我是是是是是是是是是是是是是</p>
    <button>点击</button>
    <script>
        function ajax(method,url){
            return new Promise(function(resolve){
                let xhr=new XMLHttpRequest();
                xhr.open(method,url);
                xhr.send();
                xhr.onreadystatechange=function(){
                    if(xhr.readyState===4&&xhr.status===200){
                        resolve(xhr.responseText);
                    }
                    // reject("获取取数据失败");
                }
            })
        }
        document.querySelector("button").onclick=async function(){
            let p=ajax("get","data");
            p.then(function(data){
                alert(data);
            })
        }
    </script>
</body>
</html>